<?php
	require_once( "includes/common.inc.php" );
	
	$engine = new FileDataEngine();
	
	$images = $engine->getImages();

	if ( !$images )
	{
		return NULL;
	}
	else
	{
		if ( isset( $_GET['img'] ) )
		{
			$pos = intval( $_GET['img'] );
			if ( $pos > ( count( $images ) -1 ) )
			{
				$pos = $pos % count( $images );
			}
			if ( $pos < 0 )
			{
				if ( $pos < -( count( $images ) ) )
				{
					$pos = -( (-($pos)) % count( $images ) );
				}
				$pos = count( $images ) + $pos;
				
			}
			echo $images[$pos];
		}
	}
?>